window.addEventListener('load', function () {
    //配置
    var config = {
        vx: 4,	//小球x轴速度,正为右，负为左
        vy: 4,	//小球y轴速度
        height: 2,	//小球高宽，其实为正方形，所以不宜太大
        width: 2,
        count: 200,		//点个数
        color: " #0, 189, 255", 	//点颜色
        stroke: "red", 		//线条颜色
        dist: 6000, 	//点吸附距离
        e_dist: 20000, 	//鼠标吸附加速距离
        max_conn: 10 	//点到点最大连接数
    }

    //调用
    CanvasParticle(config);
    let data = [
        { "times": 4000, "price": 1200, "unitPrice": "0.3000" },
        { "times": 8000, "price": 2000, "unitPrice": "0.2500" },
        { "times": 40000, "price": 8000, "unitPrice": "0.2000" },
    ]
    //获取事件源

    //渲染数据到html文档中
    data.forEach(function (v, i) {
        if (i == 0) {
            gitEle('.banner ul li:nth-child(4)').innerHTML += `<span class="active" class='blue'>${v.times}次</span>`
        } else {
            gitEle('.banner ul li:nth-child(4)').innerHTML += `<span class="active" >${v.times}次</span>`
        }



    })


    // 获取事件源
    let spanList = gitEleAll('.banner ul li:nth-child(4) .active')
    // 遍历数组添加点击事件
    spanList.forEach(function (v, i) {
        v.addEventListener('click', function () {
            spanList.forEach(function (v, i) {
                v.classList.remove('blue')
            })
            v.classList.add('blue')
            gitEle('.banner ul li:nth-child(5)').innerHTML = `<span>￥${data[i].price}</span>(约${data[i].unitPrice}元/次),仅限企业实名购买;`
        })
    })
    menu('.main span','active','.section','on')
    // 获取事件源b
//     let span2 = gitEleAll('.main span')
//     let content = gitEleAll('.section')
//     span2.forEach(function (v, i) {
//         v.addEventListener('click',function(){
//             span2.forEach(function(v,i){
//                 v.classList.remove('active')
//                 content[i].classList.remove('on')
//             })
//             v.classList.add('active')
//             content[i].classList.add('on')

//         })


//     })
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//窗口登录事件
let dengul=gitEle('header .right-box a:nth-child(1)')
dengul.addEventListener('click',function(){
    displayMask(this)
})
let jump=gitEleAll('header a')
jump.forEach(function(v,i){
    v.addEventListener('click',function(){
      
           if(i==0){
                window.location.href = 'index.html'
        }else if(i==1){
            window.location.href = 'api.html'
        }else if(i==2){
            window.location.href = 'unicorn.html'
        }else if(i==3){
            window.location.href = 'api log-in-1.html'
        }else{
            window.location.href = 'register.html'
        }

    })
})


})





